package com.nutshare.lt;

import com.nutshare.lt.view.PopularView;

import javax.swing.*;

public class LTWorkspace
{
    private String name;

    private Integer capacity;
    private String file;
    private Integer count;
    private Stat stat;


    private JFrame window;
    private PopularView popularView;


    public LTWorkspace(String name, Integer capacity, String file, Integer count)
    {
        this.name = name;
        this.capacity = capacity;
        this.file = file;
        this.count = count;

        stat = new Stat(this);
        stat.readFromFile(file);
        stat.calculateTotalPopular();

    }

    public void showWorkspace()
    {
        window = new JFrame(name);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        popularView = new PopularView();
        popularView.initCustom(stat);

        window.getContentPane().add(popularView);
        window.pack();
        window.setVisible(true);

    }

    public Integer getCount()
    {
        return count;
    }

    public void setCount(Integer count)
    {
        this.count = count;
    }

    public Integer getCapacity()
    {
        return capacity;
    }

    public void setCapacity(Integer capacity)
    {
        this.capacity = capacity;
    }

}
